/*
 * Copyright (C) 2017 yixun All Rights Reserved.
 * 
 * DepartmentDto.java
 */
package com.yixun.qfbao.model.dto;

import com.yixun.qfbao.model.Department;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;

/**
 * [文件名称]<br>
 * DepartmentDto.java<br>
 * <br>
 * [文件描述]<br>
 * 部门表 数据辅助类<br>
 * <br>
 * [修改记录]<br>
 * 2017-01-04 11:08:07 创建 陶俊代码生成器<br>
 * 
 * @author 陶俊代码生成器
 * @version 1.00
 */
public class DepartmentDto extends Department implements Comparable<DepartmentDto>{
	private static final long serialVersionUID = 1L;
	/**
	 *需要正序字段名
	 */
	private List<String> asc;
	/**
	 *需要逆序字段名
	 */
	private List<String> desc;
	/**
	 *排序SQL
	 */
	private String orders;
	
	/**
	 * 营业执照
	 */
	private String credential;
	
	/**
	 * 模板名称
	 */
	private String modelName;
	/**
	 * 模板类型
	 */
	private String modelType;
	
	/**
	 * 模板值
	 */
	private String modelValue;
	/**
	 *  添加需要正序字段名
	 */
	public void addAsc(String col){
		if(asc==null){
			asc = new LinkedList<String>();
		}
		asc.add(col);
	}
	
	/**
	 *  清空需要正序字段名
	 */
	public void cleanAsc(){
		asc = null;
	}
	
	/**
	 *  添加需要逆序字段名
	 */
	public void addDesc(String col){
		if(desc==null){
			desc = new LinkedList<String>();
		}
		desc.add(col);
	}
	
	/**
	 *  清空需要逆序字段名
	 */
	public void cleanDesc(){
		desc = null;
	}
	
	/**
	 *  如果排序SQL为空根据需要正逆序的字段名拼接排序SQL
	 */
	public String  getOrders() {
		StringBuilder orderStr = null;
		StringBuilder ascStr;
		StringBuilder descStr;
		if(orders==null){
			if(asc!=null){
				ascStr = new StringBuilder();
				orderStr = new StringBuilder();
				String pex = "";
				for(String a : asc){
					ascStr.append(pex+a);
					pex = ",";
				}
				orderStr.append(ascStr.toString()+" ASC");
			}
			if(desc!=null){
				descStr = new StringBuilder();
				String pex = "";
				for(String d : desc){
					descStr.append(pex+d);
					pex = ",";
				}
				if(orderStr==null){
					orderStr = new StringBuilder();
					orderStr.append(descStr.toString()+" DESC");
				}else{
					orderStr.append(","+descStr.toString()+" DESC");
				}
			}
			orders = orderStr!=null?orderStr.toString():null;
		}
		
		return orders;
	}
	
	/**
	 *  设置排序SQL
	 */
	public void setOrders(String orders) {
		this.orders = orders;
	}
	private Date updateTimeBefore;
	private Date updateTimeAfter;
	private Date createTimeBefore;
	private Date createTimeAfter;

	/**
	 *数据权限过滤条件
	 */
	private String dataPermission;

	/**
	 *对接人姓名
	 */
	private String principalName;

	/**
	 *对接人手机号
	 */
	private String principalPhone;
	/**
	 * 操作人id（用于日志记录）
	 */
	private long optUser;

	/**
	 * 合并部门id
	 */
	private Long mergeId;
	/**
	 * 接受部门id
	 */
	private Long acceptId;
	/**
	 * 合并部门层级
	 */
	private String mergeLevel;
	/**
	 * 接受部门层级
	 */
	private String acceptLevel;

	private String companyCode;

	/**
	 * 商户ids
	 */
	private String merchantIds;
	/**
	 * 子节点id,用于异步加载
	 */
	private Long childId;
	/**
	 *部门名称
	 */
	private List<String> departmentNames;
	private List<Long> deptIds;
	private Long province;
	private Long city;
	private String address;
	private List<String> permissionCodes;



	//是否需要过滤父级
	private Boolean isFilterParentLevel;

	public Boolean getIsFilterParentLevel() {
		return isFilterParentLevel;
	}

	public void setIsFilterParentLevel(Boolean filterParentLevel) {
		isFilterParentLevel = filterParentLevel;
	}

    public Date getUpdateTimeBefore() {
        return this.updateTimeBefore;
    }
    public void setUpdateTimeBefore(Date updateTimeBefore) {
        this.updateTimeBefore = updateTimeBefore;
    }

    public Date getUpdateTimeAfter() {
        return this.updateTimeAfter;
    }
    public void setUpdateTimeAfter(Date updateTimeAfter) {
        this.updateTimeAfter = updateTimeAfter;
    }
    public Date getCreateTimeBefore() {
        return this.createTimeBefore;
    }
    public void setCreateTimeBefore(Date createTimeBefore) {
        this.createTimeBefore = createTimeBefore;
    }

    public Date getCreateTimeAfter() {
        return this.createTimeAfter;
    }
    public void setCreateTimeAfter(Date createTimeAfter) {
        this.createTimeAfter = createTimeAfter;
    }


	public String getDataPermission() {
		return dataPermission;
	}

	public void setDataPermission(String dataPermission) {
		this.dataPermission = dataPermission;
	}

	public String getPrincipalName() {
		return principalName;
	}

	public void setPrincipalName(String principalName) {
		this.principalName = principalName;
	}

	public String getPrincipalPhone() {
		return principalPhone;
	}

	public void setPrincipalPhone(String principalPhone) {
		this.principalPhone = principalPhone;
	}

	public long getOptUser() {
		return optUser;
	}

	public void setOptUser(long optUser) {
		this.optUser = optUser;
	}

	public Long getMergeId() {
		return mergeId;
	}

	public void setMergeId(Long mergeId) {
		this.mergeId = mergeId;
	}

	public Long getAcceptId() {
		return acceptId;
	}

	public void setAcceptId(Long acceptId) {
		this.acceptId = acceptId;
	}

	public String getMergeLevel() {
		return mergeLevel;
	}

	public void setMergeLevel(String mergeLevel) {
		this.mergeLevel = mergeLevel;
	}

	public String getAcceptLevel() {
		return acceptLevel;
	}

	public void setAcceptLevel(String acceptLevel) {
		this.acceptLevel = acceptLevel;
	}

	public String getCompanyCode() {
		return companyCode;
	}

	public void setCompanyCode(String companyCode) {
		this.companyCode = companyCode;
	}

	public String getMerchantIds() {
		return merchantIds;
	}

	public void setMerchantIds(String merchantIds) {
		this.merchantIds = merchantIds;
	}

	public Long getChildId() {
		return childId;
	}

	public void setChildId(Long childId) {
		this.childId = childId;
	}

	public List<String> getDepartmentNames() {
		return departmentNames;
	}

	public void setDepartmentNames(List<String> departmentNames) {
		this.departmentNames = departmentNames;
	}

	public List<Long> getDeptIds() {
		return deptIds;
	}

	public void setDeptIds(List<Long> deptIds) {
		this.deptIds = deptIds;
	}

	public Long getProvince() {
		return province;
	}

	public void setProvince(Long province) {
		this.province = province;
	}

	public Long getCity() {
		return city;
	}

	public void setCity(Long city) {
		this.city = city;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Override
	public int hashCode() {
		return Objects.hash(this.getId() == null? this.getId().longValue(): null);
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof DepartmentDto) {
			DepartmentDto objDept = (DepartmentDto) obj;
			return objDept.getId().longValue() == this.getId().longValue();
		}
		return super.equals(obj);
	}

	@Override
	public int compareTo(DepartmentDto o) {
		return o.getCreateTime().compareTo(this.getCreateTime());
	}
	
	public List<String> getPermissionCodes() {
		return permissionCodes;
	}

	public void setPermissionCodes(List<String> permissionCodes) {
		this.permissionCodes = permissionCodes;
	}

	public String getModelType() {
		return modelType;
	}

	public void setModelType(String modelType) {
		this.modelType = modelType;
	}

	public String getModelName() {
		return modelName;
	}

	public void setModelName(String modelName) {
		this.modelName = modelName;
	}

	public String getModelValue() {
		return modelValue;
	}

	public void setModelValue(String modelValue) {
		this.modelValue = modelValue;
	}

	public String getCredential() {
		return credential;
	}

	public void setCredential(String credential) {
		this.credential = credential;
	}
	
}
